import { reactive } from 'vue';
// Hook
export const useAddItem = () => {
  const obj = reactive({
    arr: [
      {
        id: 0,
        name: 'ifer',
      },
      {
        id: 1,
        name: 'elser',
      },
      {
        id: 2,
        name: 'xxx',
      },
    ],
  })
  const form = reactive({
    id: '',
    name: ''
  })
  const handleAdd = () => {
    obj.arr.push({
      ...form
    })
    form.id = ''
    form.name = ''
  }
  return {
    obj,
    handleAdd,
    form
  }
}

export const useDelItem = (obj) => {
  const handleDel = (index) => {
    obj.arr.splice(index, 1)
  }
  return {
    handleDel
  }
}